//
// Source code recreated from ConfigVo .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.ht.modules.system.online.graphreport.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.io.Serializable;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import com.ht.modules.system.online.graphreport.entity.OnlGraphreportHead;
import com.ht.modules.system.online.graphreport.entity.OnlGraphreportItem;
import com.ht.modules.system.online.graphreport.mapper.OnlGraphreportHeadMapper;
import com.ht.modules.system.online.graphreport.mapper.OnlGraphreportItemMapper;
import com.ht.modules.system.online.graphreport.service.IOnlGraphreportHeadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class OnlGraphreportHeadServiceImpl extends ServiceImpl<OnlGraphreportHeadMapper, OnlGraphreportHead> implements IOnlGraphreportHeadService {
    @Autowired
    private OnlGraphreportHeadMapper onlGraphreportHeadMapper;
    @Autowired
    private OnlGraphreportItemMapper onlGraphreportItemMapper;

    public OnlGraphreportHeadServiceImpl() {
    }

    public List<Map<?, ?>> executeSelete(String sql) {
        return this.onlGraphreportHeadMapper.executeSelete(sql);
    }

    @Transactional(
        rollbackFor = {Exception.class}
    )
    public void saveMain(OnlGraphreportHead onlGraphreportHead, List<OnlGraphreportItem> onlGraphreportItemList) {
        if (onlGraphreportHead.getYaxisText() == null) {
            onlGraphreportHead.setYaxisText("yaxis_text");
        }

        this.onlGraphreportHeadMapper.insert(onlGraphreportHead);
        Iterator var3 = onlGraphreportItemList.iterator();

        while(var3.hasNext()) {
            OnlGraphreportItem entity = (OnlGraphreportItem)var3.next();
            entity.setGraphreportHeadId(onlGraphreportHead.getId());
            this.onlGraphreportItemMapper.insert(entity);
        }

    }

    @Transactional(
        rollbackFor = {Exception.class}
    )
    public void updateMain(OnlGraphreportHead onlGraphreportHead, List<OnlGraphreportItem> onlGraphreportItemList) {
        this.onlGraphreportHeadMapper.updateById(onlGraphreportHead);
        this.onlGraphreportItemMapper.deleteByMainId(onlGraphreportHead.getId());
        Iterator var3 = onlGraphreportItemList.iterator();

        while(var3.hasNext()) {
            OnlGraphreportItem entity = (OnlGraphreportItem)var3.next();
            entity.setGraphreportHeadId(onlGraphreportHead.getId());
            this.onlGraphreportItemMapper.insert(entity);
        }

    }

    @Transactional(
        rollbackFor = {Exception.class}
    )
    public void delMain(String id) {
        this.onlGraphreportHeadMapper.deleteById(id);
        this.onlGraphreportItemMapper.deleteByMainId(id);
    }

    @Transactional(
        rollbackFor = {Exception.class}
    )
    public void delBatchMain(Collection<? extends Serializable> idList) {
        Iterator var2 = idList.iterator();

        while(var2.hasNext()) {
            Serializable id = (Serializable)var2.next();
            this.onlGraphreportHeadMapper.deleteById(id);
            this.onlGraphreportItemMapper.deleteByMainId(id.toString());
        }

    }

    public OnlGraphreportHead queryByCode(String code) {
        QueryWrapper<OnlGraphreportHead> queryWrapper = new QueryWrapper();
        queryWrapper.eq("code", code);
        return (OnlGraphreportHead)this.getOne(queryWrapper);
    }
}
